package com.ds.infrastructure.hyperspace.console.model.request.containerconfig.configdata;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.ds.infrastructure.hyperspace.console.dto.configdata.PreflowDTO;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;

/**
 * @author: yaozhendong
 * @create: 2019-09-20 16:41
 **/
@Data
@NoArgsConstructor
public class PreflowForm {
    @NotBlank
    private String id;

    private Long handlerId;

    @NotBlank
    private String handler;
    @NotEmpty
    @JsonProperty("handlerParams")
    private List<String> handlerparams;

    public static PreflowDTO toDTO(PreflowForm item) {
        PreflowDTO preflowDTO = new PreflowDTO();
        preflowDTO.setId(item.getId());
        preflowDTO.setHandlerId(item.getHandlerId());
        preflowDTO.setHandler(item.getHandler());
        preflowDTO.setHandlerparams(item.getHandlerparams());
        return preflowDTO;
    }


    public static PreflowForm toVO(PreflowDTO dto) {
        PreflowForm preflowFrom = new PreflowForm();
        preflowFrom.setId(dto.getId());
        preflowFrom.setHandlerId(dto.getHandlerId());
        preflowFrom.setHandler(dto.getHandler());
        preflowFrom.setHandlerparams(dto.getHandlerparams());
        return preflowFrom;
    }
}
